//
//  UIButton+CreatUI.m
//  QuXiang
//
//  Created by Duncan on 2020/6/17.
//  Copyright © 2020 NanHuaiZi. All rights reserved.
//

#import "UIButton+CreatUI.h"

@implementation UIButton (CreatUI)

+ (UIButton *)initWithTitle:(NSString *)title titleColor:(UIColor *)titleColor fontSize:(NSInteger)fontSize {
    return [UIButton initWithImage:nil selectedImage:nil title:title selectedTitle:nil titleColor:titleColor selectedTitleColor:nil font:kAdaptedFontSize(fontSize)];
}

+ (UIButton *)initWithTitle:(NSString *)title titleColor:(UIColor *)titleColor mediumFontSize:(NSInteger)mediumFontSize {
    return [UIButton initWithImage:nil selectedImage:nil title:title selectedTitle:nil titleColor:titleColor selectedTitleColor:nil font:kAdaptedMediumFontSize(mediumFontSize)];
}

+ (UIButton *)initWithTitle:(NSString *)title titleColor:(UIColor *)titleColor boldFontSize:(NSInteger)fontSize {
    return [UIButton initWithImage:nil selectedImage:nil title:title selectedTitle:nil titleColor:titleColor selectedTitleColor:nil font:kAdaptedBoldFontSize(fontSize)];
}

+ (UIButton *)initWithImage:(UIImage *)image selectedImage:(UIImage * __nullable)selectedImage {
    return [UIButton initWithImage:image selectedImage:selectedImage title:nil selectedTitle:nil titleColor:nil selectedTitleColor:nil font:nil];
}

+ (UIButton *)initWithImage:(UIImage *)image selectedImage:(UIImage *)selectedImage title:(NSString *)title selectedTitle:(NSString *)selectedTitle titleColor:(UIColor *)titleColor selectedTitleColor:(UIColor *)selectedTitleColor font:(UIFont *)font {
    
    UIButton *button = [[UIButton alloc] init];
    button.titleLabel.font = font;
    
    [button setTitle:title forState:UIControlStateNormal];
    [button setImage:image forState:UIControlStateNormal];
    [button setTitleColor:titleColor forState:UIControlStateNormal];

    [button setTitle:selectedTitle forState:UIControlStateSelected];
    [button setImage:selectedImage forState:UIControlStateSelected];
    [button setTitleColor:selectedTitleColor forState:UIControlStateSelected];
    
    return button;
}

@end
